package cn.dlc.com.user;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 邓立川
 * @date 2021/11/28 11:32
 * @desc 当前类的描述信息
 */
@RestController
@RequestMapping("user")
public class UserController {

    @GetMapping("{id}")
    @PreAuthorize("hasAnyAuthority('p1')")
    public String tes1(@PathVariable("id")String id){

        String name = SecurityContextHolder.getContext().getAuthentication().getName();

        System.out.println("name：" + name);
        System.out.println("name：" + name);
        System.out.println("name：" + name);
        System.out.println("name：" + name);

        return "res1: " + id + " " + name;
    }
}
